package org.apix.commands;

import org.apix.Apix;
import org.apix.configuration.PlayerStorageData;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class WaprCommandExecutor implements CommandExecutor {

	
	ChatColor white = ChatColor.WHITE;
	ChatColor red = ChatColor.RED;
	 
	public WaprCommandExecutor(Apix plugin) {
		
	}

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		if(sender instanceof Player){
			Player player = (Player)sender;			
        	
			if(cmd.getName().equalsIgnoreCase("sethome")){
				PlayerStorageData.getInstance(player).setHome();
        		player.sendMessage(white + "Your " + red + "home" + white + " has been set.");
        		//player.setFoodLevel(player.getFoodLevel()/2);
	        }
			if(cmd.getName().equalsIgnoreCase("home")){	
				player.teleport(PlayerStorageData.getInstance(player).getHome());
				player.setFoodLevel((player.getFoodLevel()/2));
				
				player.sendMessage(white + "Teleported " + red + "home" + white + ".");
				
			}
		}
		return false;
	}

}
